package thread.simpletest;

import org.junit.Test;

/**
 * @author liweimin
 * @date 2021/4/26 10:03
 * @since
 */
public class SimpleTest {
    @Test
    public void test1() {
        MyThread myThread = new MyThread();//main thread
        System.out.println(myThread.isAlive());
        System.out.println(myThread.isDaemon());
        System.out.println(myThread.isInterrupted());
        myThread.run();//main thread

        myThread.start();//sub thread

        new Thread(myThread).start();

        System.out.println(myThread.isAlive());
        System.out.println(myThread.isDaemon());
        System.out.println(myThread.isInterrupted());

    }

    public static void main(String[] args) {
        System.out.println("main_begin :" + System.currentTimeMillis());

        new Thread(() -> {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("subThread_end: " + System.currentTimeMillis());
        }, "subThread_end").start();

        System.out.println("main_end :" + System.currentTimeMillis());
    }
}


class MyThread extends Thread {
    @Override
    public void run() {
        System.out.println("run method:" + Thread.currentThread().getName());
    }

    public MyThread() {
        System.out.println("constructor method:" + Thread.currentThread().getName());
    }
}
